/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.hangim.pce.common.web;

import com.hangim.pce.enums.*;
import com.hangim.pce.feign.UserService;
import com.github.pig.common.util.UserUtils;
import com.github.pig.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hongjiliang
 * @date 2017/10/28
 */
@RestController
public class PceBaseController extends BaseController {

    @Autowired
    private UserService userService;

    /**
     * 获取登录用户ID
     *
     * @return 角色名
     */
    public Long getCurUserId() {
        if (UserUtils.getUser() != null) {
            return userService.findUserByUsername(UserUtils.getUser()).getUserId().longValue();
        }
        return null;
    }

    /**
     * 获取人群类型
     */
    @RequestMapping("/peopleType")
    public List<PeopleType> getPeopleType() {
        return PeopleType.getList();
    }

    /**
     * 获取用法类型
     */
    @RequestMapping("/usageType")
    public List<UsageType> getUsageType() {
        return UsageType.getList();
    }

    /**
     * 获取规则等级
     */
    @RequestMapping("/ruleLevel")
    public List<RuleLevel> getRuleLevel() {
        return RuleLevel.getList();
    }

    /**
     * 获取药品功用类型
     */
    @RequestMapping("/drugUsageType")
    public List<DrugUsageType> getDrugUsageType() {
        return DrugUsageType.getList();
    }

    /**
     * 获取字典类型
     */
    @RequestMapping("/dictType")
    public List<DictType> getDictType() {
        return DictType.getList();
    }

    /**
     * 获取用量单位
     */
    @RequestMapping("/doseUnit")
    public List<DoseUnit> getDoseUnit() {
        return DoseUnit.getList();
    }

    /**
     * 获取药品类型
     */
    @RequestMapping("/drugType")
    public List<DrugType> getDrugType() {
        return DrugType.getList();
    }

    /**
     * 获取频次单位
     */
    @RequestMapping("/freqUnit")
    public List<TimeUnit> getFreqUnit() {
        return TimeUnit.getList();
    }

}
